package com.heima.admin.controller.v1;

import com.heima.admin.service.SensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "敏感词管理接口",tags = "敏感词接口")
@RestController
@RequestMapping("/api/v1/sensitive")
public class SensitiveWordController {
    //注入service
    @Autowired
    private SensitiveService service;
    /**
     * 分页条件查询敏感词
     */
    @ApiOperation("分页查询敏感词")
    @PostMapping("/list")
    public ResponseResult fingSensitiveByPage(@RequestBody SensitiveDto sensitiveDto){
       return service.fingSensitiveByPage(sensitiveDto);
    }

    /**
     * 保存敏感词
     */
    @ApiOperation("保存敏感词")
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody AdSensitive sensitive){
        return service.saveSensitive(sensitive);
    }

    /**
     * 修改敏感词
     */
    @ApiOperation("修改敏感词")
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive sensitive){
        return service.updateSensitive(sensitive);
    }

    /**
     * 根据id删除敏感词
     */
    @ApiOperation("删除敏感词")
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitiveById(@PathVariable Integer id){
        return service.deleteSensitiveById(id);
    }

    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return service.selectAllSensitives();
    }
}
